<!--
* @author wn
* @date 2023/02/27 11:14:27
* @description: 语言切换组件
!-->
<template>
	<!-- v-model:value="$i18n.locale" -->
	<a-space>
		<a-select v-model:value="lang" style="width: 70px" @change="handleChange">
			<a-select-option
				v-for="(item, index) in localeArray"
				:key="index"
				:value="item"
				>{{ item === 'zh_CN' ? '中文' : item }}
			</a-select-option>
		</a-select>
	</a-space>
</template>
<script setup>
import { useLocale } from '@/stores/modules/localeStore'
import { storeToRefs } from 'pinia'
import { useChangeLocale } from '@/locales/useLocale'
import { ref } from 'vue'

const { locale, localeArray } = storeToRefs(useLocale())
// 默认语言
const lang = ref(locale.value)
// 点击切换语言
const handleChange = value => useChangeLocale(value)
</script>
<style scoped lang="less"></style>
